﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using agvcontroller.Process;
using agvcontroller.Log;

namespace agvcontroller.GUI
{
    /// <summary>
    /// Interaction logic for UCLogDisplay.xaml
    /// </summary>
    public partial class UCLogDisplay : UserControl
    {
        public UCLogDisplay()
        {
            InitializeComponent();

            RegisetEvent();

        }

        void RegisetEvent()
        {
            Logger.onDisplayLog +=new deleLogDisplay(Logger_onDisplayLog);
        }

        void Logger_onDisplayLog(object sender, string msg, enumLogLevel level)
        {
            DisplayMsg(msg);
        }

        void DisplayMsg(string msg)
        {
            System.Windows.Threading.DispatcherOperation
         dispatcherOp = tbLog.Dispatcher.BeginInvoke(
         System.Windows.Threading.DispatcherPriority.Normal,
         new Action(
           delegate()
           {
               tbLog.AppendText(msg + "\r\n");
               tbLog.ScrollToEnd();
           }
        ));
        }
    }
}
